#include "number.h"

int complex_re_enclose_p (Complex* a, Complex* b)
{
    return interval_span_p(a->re, b->re->l) && interval_span_p(a->re, b->re->u);
}

int complex_re_contain_l_p (Complex* a, Complex* b)
{
    return interval_span_p(a->re, b->re->l);
}

int complex_re_contain_n_p (Complex* a, Complex* b)
{
    return interval_span_p(a->re, b->re->n);
}

int complex_re_contain_u_p (Complex* a, Complex* b)
{
    return interval_span_p(a->re, b->re->u);
}

int complex_re_contain_zero_p (Complex* complex)
{
    return interval_span_zero_p(complex->re);
}

int complex_re_intersect_p (Complex* a, Complex* b)
{
    return interval_span_p(a->re, b->re->l) || interval_span_p(a->re, b->re->u) || interval_span_p(b->re, a->re->n);
}

int complex_re_disjoint_p (Complex* a, Complex* b)
{
    return !complex_re_intersect_p(a, b);
}

int complex_re_unbounded_p (Complex* complex)
{
    return NEG_INF(complex->re->l) && POS_INF(complex->re->u);
}

int complex_re_left_unbounded_p (Complex* complex)
{
    return NEG_INF(complex->re->l);
}

int complex_re_right_unbounded_p (Complex* complex)
{
    return POS_INF(complex->re->u);
}

int complex_re_nan_p (Complex* complex)
{
    return NaN(complex->re->n);
}

int complex_re_pos_inf_p (Complex* complex)
{
    return POS_INF(complex->re->n);
}

int complex_re_neg_inf_p (Complex* complex)
{
    return POS_INF(complex->re->n);
}

int complex_re_normal_p (Complex* complex)
{
    return REAL(complex->re->n);
}

int complex_re_zero_p (Complex* complex)
{
    return ZERO(complex->re->n);
}

int complex_re_eq_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->l, b->re->l) && real_eq_p(a->re->n, b->re->n) && real_eq_p(a->re->u, b->re->u) && (a->re->L == b->re->L) && (a->re->R == b->re->R);
}

int complex_re_bounds_eq_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->l, b->re->l) && real_eq_p(a->re->u, b->re->u) && (a->re->L == b->re->L) && (a->re->R == b->re->R);
}

int complex_re_l_eq_l_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->l, b->re->l);
}

int complex_re_l_eq_n_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->l, b->re->n);
}

int complex_re_l_eq_u_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->l, b->re->u);
}

int complex_re_n_eq_l_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->n, b->re->l);
}

int complex_re_n_eq_n_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->n, b->re->n);
}

int complex_re_n_eq_u_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->n, b->re->u);
}

int complex_re_u_eq_l_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->u, b->re->l);
}

int complex_re_u_eq_n_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->u, b->re->n);
}

int complex_re_u_eq_u_p (Complex* a, Complex* b)
{
    return real_eq_p(a->re->u, b->re->u);
}

int complex_re_l_gt_l_p (Complex* a, Complex* b)
{
    return real_gt_p(a->re->l, b->re->l);
}

int complex_re_l_gt_n_p (Complex* a, Complex* b)
{
    return real_gt_p(a->re->l, b->re->n);
}

int complex_re_l_gt_u_p (Complex* a, Complex* b)
{
    return real_gt_p(a->re->l, b->re->u);
}

int complex_re_n_gt_l_p (Complex* a, Complex* b)
{
    return real_gt_p(a->re->n, b->re->l);
}

int complex_re_n_gt_n_p (Complex* a, Complex* b)
{
    return real_gt_p(a->re->n, b->re->n);
}

int complex_re_n_gt_u_p (Complex* a, Complex* b)
{
    return real_gt_p(a->re->n, b->re->u);
}

int complex_re_u_gt_l_p (Complex* a, Complex* b)
{
    return real_gt_p(a->re->u, b->re->l);
}

int complex_re_u_gt_n_p (Complex* a, Complex* b)
{
    return real_gt_p(a->re->u, b->re->n);
}

int complex_re_u_gt_u_p (Complex* a, Complex* b)
{
    return real_gt_p(a->re->u, b->re->u);
}

int complex_re_l_ge_l_p (Complex* a, Complex* b)
{
    return real_ge_p(a->re->l, b->re->l);
}

int complex_re_l_ge_n_p (Complex* a, Complex* b)
{
    return real_ge_p(a->re->l, b->re->n);
}

int complex_re_l_ge_u_p (Complex* a, Complex* b)
{
    return real_ge_p(a->re->l, b->re->u);
}

int complex_re_n_ge_l_p (Complex* a, Complex* b)
{
    return real_ge_p(a->re->n, b->re->l);
}

int complex_re_n_ge_n_p (Complex* a, Complex* b)
{
    return real_ge_p(a->re->n, b->re->n);
}

int complex_re_n_ge_u_p (Complex* a, Complex* b)
{
    return real_ge_p(a->re->n, b->re->u);
}

int complex_re_u_ge_l_p (Complex* a, Complex* b)
{
    return real_ge_p(a->re->u, b->re->l);
}

int complex_re_u_ge_n_p (Complex* a, Complex* b)
{
    return real_ge_p(a->re->u, b->re->n);
}

int complex_re_u_ge_u_p (Complex* a, Complex* b)
{
    return real_ge_p(a->re->u, b->re->u);
}

int complex_re_l_lt_l_p (Complex* a, Complex* b)
{
    return real_lt_p(a->re->l, b->re->l);
}

int complex_re_l_lt_n_p (Complex* a, Complex* b)
{
    return real_lt_p(a->re->l, b->re->n);
}

int complex_re_l_lt_u_p (Complex* a, Complex* b)
{
    return real_lt_p(a->re->l, b->re->u);
}

int complex_re_n_lt_l_p (Complex* a, Complex* b)
{
    return real_lt_p(a->re->n, b->re->l);
}

int complex_re_n_lt_n_p (Complex* a, Complex* b)
{
    return real_lt_p(a->re->n, b->re->n);
}

int complex_re_n_lt_u_p (Complex* a, Complex* b)
{
    return real_lt_p(a->re->n, b->re->u);
}

int complex_re_u_lt_l_p (Complex* a, Complex* b)
{
    return real_lt_p(a->re->u, b->re->l);
}

int complex_re_u_lt_n_p (Complex* a, Complex* b)
{
    return real_lt_p(a->re->u, b->re->n);
}

int complex_re_u_lt_u_p (Complex* a, Complex* b)
{
    return real_lt_p(a->re->u, b->re->u);
}

int complex_re_l_le_l_p (Complex* a, Complex* b)
{
    return real_le_p(a->re->l, b->re->l);
}

int complex_re_l_le_n_p (Complex* a, Complex* b)
{
    return real_le_p(a->re->l, b->re->n);
}

int complex_re_l_le_u_p (Complex* a, Complex* b)
{
    return real_le_p(a->re->l, b->re->u);
}

int complex_re_n_le_l_p (Complex* a, Complex* b)
{
    return real_le_p(a->re->n, b->re->l);
}

int complex_re_n_le_n_p (Complex* a, Complex* b)
{
    return real_le_p(a->re->n, b->re->n);
}

int complex_re_n_le_u_p (Complex* a, Complex* b)
{
    return real_le_p(a->re->n, b->re->u);
}

int complex_re_u_le_l_p (Complex* a, Complex* b)
{
    return real_le_p(a->re->u, b->re->l);
}

int complex_re_u_le_n_p (Complex* a, Complex* b)
{
    return real_le_p(a->re->u, b->re->n);
}

int complex_re_u_le_u_p (Complex* a, Complex* b)
{
    return real_le_p(a->re->u, b->re->u);
}

int complex_im_unbounded_p (Complex* complex)
{
    return NEG_INF(complex->im->l) && POS_INF(complex->im->u);
}

int complex_im_left_unbounded_p (Complex* complex)
{
    return NEG_INF(complex->im->l);
}

int complex_im_right_unbounded_p (Complex* complex)
{
    return POS_INF(complex->im->u);
}

int complex_im_nan_p (Complex* complex)
{
    return NaN(complex->im->n);
}

int complex_im_pos_inf_p (Complex* complex)
{
    return POS_INF(complex->im->n);
}

int complex_im_neg_inf_p (Complex* complex)
{
    return POS_INF(complex->im->n);
}

int complex_im_normal_p (Complex* complex)
{
    return REAL(complex->im->n);
}

int complex_im_zero_p (Complex* complex)
{
    return ZERO(complex->im->n);
}

int complex_im_contain_zero_p (Complex* complex)
{
    return interval_span_zero_p(complex->im);
}

int complex_im_enclose_p (Complex* a, Complex* b)
{
    return interval_span_p(a->im, b->im->l) && interval_span_p(a->im, b->im->u);
}

int complex_im_contain_l_p (Complex* a, Complex* b)
{
    return interval_span_p(a->im, b->im->l);
}

int complex_im_contain_n_p (Complex* a, Complex* b)
{
    return interval_span_p(a->im, b->im->n);
}

int complex_im_contain_u_p (Complex* a, Complex* b)
{
    return interval_span_p(a->im, b->im->u);
}

int complex_im_intersect_p (Complex* a, Complex* b)
{
    return interval_span_p(a->im, b->im->l) || interval_span_p(a->im, b->im->u) || interval_span_p(b->im, a->im->n);
}

int complex_im_disjoint_p (Complex* a, Complex* b)
{
    return !complex_im_intersect_p(a, b);
}

int complex_im_eq_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->l, b->im->l) && real_eq_p(a->im->n, b->im->n) && real_eq_p(a->im->u, b->im->u) && (a->im->L == b->im->L) && (a->im->R == b->im->R);
}

int complex_im_bounds_eq_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->l, b->im->l) && real_eq_p(a->im->u, b->im->u) && (a->im->L == b->im->L) && (a->im->R == b->im->R);
}

int complex_im_l_eq_l_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->l, b->im->l);
}

int complex_im_l_eq_n_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->l, b->im->n);
}

int complex_im_l_eq_u_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->l, b->im->u);
}

int complex_im_n_eq_l_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->n, b->im->l);
}

int complex_im_n_eq_n_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->n, b->im->n);
}

int complex_im_n_eq_u_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->n, b->im->u);
}

int complex_im_u_eq_l_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->u, b->im->l);
}

int complex_im_u_eq_n_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->u, b->im->n);
}

int complex_im_u_eq_u_p (Complex* a, Complex* b)
{
    return real_eq_p(a->im->u, b->im->u);
}

int complex_im_l_gt_l_p (Complex* a, Complex* b)
{
    return real_gt_p(a->im->l, b->im->l);
}

int complex_im_l_gt_n_p (Complex* a, Complex* b)
{
    return real_gt_p(a->im->l, b->im->n);
}

int complex_im_l_gt_u_p (Complex* a, Complex* b)
{
    return real_gt_p(a->im->l, b->im->u);
}

int complex_im_n_gt_l_p (Complex* a, Complex* b)
{
    return real_gt_p(a->im->n, b->im->l);
}

int complex_im_n_gt_n_p (Complex* a, Complex* b)
{
    return real_gt_p(a->im->n, b->im->n);
}

int complex_im_n_gt_u_p (Complex* a, Complex* b)
{
    return real_gt_p(a->im->n, b->im->u);
}

int complex_im_u_gt_l_p (Complex* a, Complex* b)
{
    return real_gt_p(a->im->u, b->im->l);
}

int complex_im_u_gt_n_p (Complex* a, Complex* b)
{
    return real_gt_p(a->im->u, b->im->n);
}

int complex_im_u_gt_u_p (Complex* a, Complex* b)
{
    return real_gt_p(a->im->u, b->im->u);
}

int complex_im_l_ge_l_p (Complex* a, Complex* b)
{
    return real_ge_p(a->im->l, b->im->l);
}

int complex_im_l_ge_n_p (Complex* a, Complex* b)
{
    return real_ge_p(a->im->l, b->im->n);
}

int complex_im_l_ge_u_p (Complex* a, Complex* b)
{
    return real_ge_p(a->im->l, b->im->u);
}

int complex_im_n_ge_l_p (Complex* a, Complex* b)
{
    return real_ge_p(a->im->n, b->im->l);
}

int complex_im_n_ge_n_p (Complex* a, Complex* b)
{
    return real_ge_p(a->im->n, b->im->n);
}

int complex_im_n_ge_u_p (Complex* a, Complex* b)
{
    return real_ge_p(a->im->n, b->im->u);
}

int complex_im_u_ge_l_p (Complex* a, Complex* b)
{
    return real_ge_p(a->im->u, b->im->l);
}

int complex_im_u_ge_n_p (Complex* a, Complex* b)
{
    return real_ge_p(a->im->u, b->im->n);
}

int complex_im_u_ge_u_p (Complex* a, Complex* b)
{
    return real_ge_p(a->im->u, b->im->u);
}

int complex_im_l_lt_l_p (Complex* a, Complex* b)
{
    return real_lt_p(a->im->l, b->im->l);
}

int complex_im_l_lt_n_p (Complex* a, Complex* b)
{
    return real_lt_p(a->im->l, b->im->n);
}

int complex_im_l_lt_u_p (Complex* a, Complex* b)
{
    return real_lt_p(a->im->l, b->im->u);
}

int complex_im_n_lt_l_p (Complex* a, Complex* b)
{
    return real_lt_p(a->im->n, b->im->l);
}

int complex_im_n_lt_n_p (Complex* a, Complex* b)
{
    return real_lt_p(a->im->n, b->im->n);
}

int complex_im_n_lt_u_p (Complex* a, Complex* b)
{
    return real_lt_p(a->im->n, b->im->u);
}

int complex_im_u_lt_l_p (Complex* a, Complex* b)
{
    return real_lt_p(a->im->u, b->im->l);
}

int complex_im_u_lt_n_p (Complex* a, Complex* b)
{
    return real_lt_p(a->im->u, b->im->n);
}

int complex_im_u_lt_u_p (Complex* a, Complex* b)
{
    return real_lt_p(a->im->u, b->im->u);
}

int complex_im_l_le_l_p (Complex* a, Complex* b)
{
    return real_le_p(a->im->l, b->im->l);
}

int complex_im_l_le_n_p (Complex* a, Complex* b)
{
    return real_le_p(a->im->l, b->im->n);
}

int complex_im_l_le_u_p (Complex* a, Complex* b)
{
    return real_le_p(a->im->l, b->im->u);
}

int complex_im_n_le_l_p (Complex* a, Complex* b)
{
    return real_le_p(a->im->n, b->im->l);
}

int complex_im_n_le_n_p (Complex* a, Complex* b)
{
    return real_le_p(a->im->n, b->im->n);
}

int complex_im_n_le_u_p (Complex* a, Complex* b)
{
    return real_le_p(a->im->n, b->im->u);
}

int complex_im_u_le_l_p (Complex* a, Complex* b)
{
    return real_le_p(a->im->u, b->im->l);
}

int complex_im_u_le_n_p (Complex* a, Complex* b)
{
    return real_le_p(a->im->u, b->im->n);
}

int complex_im_u_le_u_p (Complex* a, Complex* b)
{
    return real_le_p(a->im->u, b->im->u);
}

int complex_enclose_p (Complex* a, Complex* b)
{
    return complex_re_enclose_p(a, b) && complex_im_enclose_p(a, b);
}

int complex_contain_ll_p (Complex* a, Complex* b)
{
    return complex_re_contain_l_p(a, b) && complex_im_contain_l_p(a, b);
}

int complex_contain_lu_p (Complex* a, Complex* b)
{
    return complex_re_contain_l_p(a, b) && complex_im_contain_u_p(a, b);
}

int complex_contain_n_p (Complex* a, Complex* b)
{
    return complex_re_contain_n_p(a, b) && complex_im_contain_n_p(a, b);
}

int complex_contain_ul_p (Complex* a, Complex* b)
{
    return complex_re_contain_u_p(a, b) && complex_im_contain_l_p(a, b);
}

int complex_contain_uu_p (Complex* a, Complex* b)
{
    return complex_re_contain_u_p(a, b) && complex_im_contain_u_p(a, b);
}

int complex_contain_zero_p (Complex* complex)
{
    return interval_span_zero_p(complex->re) && interval_span_zero_p(complex->im);
}

int complex_intersect_p (Complex* a, Complex* b)
{
    return ( complex_re_intersect_p(a, b) && complex_im_intersect_p(a, b)) || complex_contain_ll_p(a, b) || complex_contain_lu_p(a, b) || complex_contain_ul_p(a, b) || complex_contain_uu_p(a, b) || ((complex_re_enclose_p(a, b) && complex_im_enclose_p(b, a)) || (complex_im_enclose_p(a, b) && complex_re_enclose_p(b, a)));
}

int complex_disjoint_p (Complex* a, Complex* b)
{
    return !complex_intersect_p(a, b);
}

int complex_unbounded_p (Complex* complex)
{
    return complex_re_unbounded_p(complex) && complex_im_unbounded_p(complex);
}

int complex_nan_p (Complex* complex)
{
    return complex_re_nan_p(complex) && complex_im_nan_p(complex);
}

int complex_normal_p (Complex* complex)
{
    return complex_re_normal_p(complex) && complex_im_normal_p(complex);
}

int complex_zero_p (Complex* complex)
{
    return complex_re_zero_p(complex) && complex_im_zero_p(complex);
}

int complex_complex_p (Complex* complex)
{
    return !complex_im_zero_p(complex);
}

int complex_real_p (Complex* complex)
{
    return complex_re_normal_p(complex) && complex_im_zero_p(complex);
}

int complex_eq_p (Complex* a, Complex* b)
{
    return complex_re_eq_p(a, b) && complex_im_eq_p(a, b);
}

int complex_bounds_eq_p (Complex* a, Complex* b)
{
    return complex_re_bounds_eq_p(a, b) && complex_im_bounds_eq_p(a, b);
}
